package Ctr;

/**
 * @author Patrick
 */

import java.util.ArrayList;

import DB.DBClothing;
import DB.DBEquipment;
import DB.DBGunReplicas;
import DB.DBProduct;
import Gui.Terminal;
import Model.Clothing;
import Model.Equipment;
import Model.GunReplicas;
import Model.Product;

public class CtrProduct {
	
	public CtrProduct()
	{
		
	}
	public ArrayList<Product> findAllProducts()
	{
		DBProduct prod = new DBProduct();
		ArrayList<Product> allProducts = new ArrayList<Product>();
		allProducts = prod.getAllProducts();
		return(allProducts);
	}
	public Product findProduct(String ID)
	{
		DBProduct prod = new DBProduct();
		return prod.getProduct(ID);
	}
	public void updateSupplier(String prodID, String name, double pPrice, double sPrice, String country, String prodType, int stock, int minStock)
	{
		DBProduct prod = new DBProduct();
		if(prod.DeleteProduct(prodID) == true)
		{
			int i = Integer.parseInt(prod.getHighestNo()) + 1;
			String HighNo = Integer.toString(i);
			Terminal.say(HighNo);
			Product product = new Product(HighNo, name, pPrice, sPrice, country, prodType, stock, minStock);
			prod.InsertProduct(product);
		}
		
	}
	public void createProduct(String prodID, String name, double pPrice, double sPrice, String country, String prodType, int stock, int minStock, String extra1, String extra2)
	{
		
		if(prodType.equals("Clothing")) {
			DBClothing clothing = new DBClothing();
			Clothing cloth = new Clothing(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			clothing.CreateClothing(cloth);
		} else if(prodType.equals("Equipment")) {
			DBEquipment equipment = new DBEquipment();
			Equipment equip = new Equipment(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			equipment.CreateEquipment(equip);
		} else if(prodType.equals("GunReplicas")) {
			DBGunReplicas gunReplicas = new DBGunReplicas();
			GunReplicas guns = new GunReplicas(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			gunReplicas.CreateGunReplicas(guns);
		} 
		else {
			Terminal.say("Wrong type");
		}
	}
	public void updateProduct(String prodID, String name, double pPrice, double sPrice, String country, String prodType, int stock, int minStock, String extra1, String extra2)
	{
		/*if(prodType.equals("Clothing")) {
			DBClothing clothing = new DBClothing();
			//clothing.UpdateClothing(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			
		} else if(prodType.equals("Equipment")) {
			DBEquipment equipment = new DBEquipment();
			Equipment equip = new Equipment(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			equipment.CreateEquipment(equip);
		} else if(prodType.equals("GunReplicas")) {
			DBGunReplicas gunReplicas = new DBGunReplicas();
			GunReplicas guns = new GunReplicas(prodID, name, pPrice, sPrice, country, prodType, stock, minStock, extra1, extra2);
			gunReplicas.CreateGunReplicas(guns);
		} 
		else {
			Terminal.say("Wrong type");
		}*/
	}
}
